package com.dreamers.core;

import javax.swing.*;
import java.awt.*;

public class BootStrap extends JFrame {

    Thread thread;
    EngineRunnable engineRunnable = new EngineRunnable();


    public BootStrap() {

        this.setPreferredSize(new Dimension(Global.GAMEWIDTH, Global.GAMEHEIGHT));
        this.setMaximumSize(new Dimension(Global.GAMEWIDTH, Global.GAMEHEIGHT));
        this.setMinimumSize(new Dimension(Global.GAMEWIDTH, Global.GAMEHEIGHT));
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.add(engineRunnable);
        this.setLayout(null);
        this.setVisible(true);


        MonoBehaviourManager.INSTANCE.init();
        start();
    }


    public synchronized void start() {
        thread = new Thread(engineRunnable);
        thread.start();
    }

    public synchronized void stop() {
        try {
            thread.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void main(String args[]) {
        new BootStrap();
    }


}
